package hw2;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.LinkedList;
import java.util.List;


public class TestFileReader {

	public String parse(String splitter, InputStream is) {
		String result = "";
		
		BufferedReader br = new BufferedReader(new InputStreamReader(is));
		List<String> lines = new LinkedList<String>();
		String line;
		try
		{
			while ((line = br.readLine()) != null && line.length() > 0)
			{
				lines.add(line);
			}
		}
		catch (IOException ex)
		{
			ex.printStackTrace();
			return null;
		}
		
		for (String s : lines)
		{
			String[] strings = s.split(splitter);
			
			for (String c : strings)
			{
				result += c;
			}
		}
		
		return result;
	}
}
